﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;

using jQuery.Validation.DataAnnotations;

namespace jQuery.Validation.Tests
{
    [TestFixture]
    public class DateAttributeTest
    {   

        [Test]
        [Row("1/1/2009")]
        [Row("1-1-2009")]
        [Row("1/13/2009")]
        [Row("12/1/2009")]
        public void IsValidForCorrectStrings(object value)
        {
            DateAttribute attr = new DateAttribute();
            Assert.IsTrue(attr.IsValid(value));
        }

        [Test]
        public void IsValidForDateValues(object value)
        {
            DateAttribute attr = new DateAttribute();
            Assert.IsTrue(attr.IsValid(DateTime.Today));
        }

        [Test]
        public void IsValidForNullValue()
        {
            DateAttribute attr = new DateAttribute();
            Assert.IsTrue(attr.IsValid(null));
        }

        [Test]
        [Row("13/1/2009")]
        [Row("test string")]
        public void IsNotValidForIncorrectStrings(string value)
        {
            DateAttribute attr = new DateAttribute();
            Assert.IsFalse(attr.IsValid(value));
        }

        [Test]
        public void IsNotValidForIntegerObjects()
        {
            DateAttribute attr = new DateAttribute();
            Assert.IsFalse(attr.IsValid(123));
        }
    }
}
